from pymongo import MongoClient
from app.core.config import MONGODB_URI, DATABASE_NAME

client = MongoClient(MONGODB_URI)
db = client[DATABASE_NAME]

class UserCRUD:
    @staticmethod
    async def create_user(user_data):
        return await db.users.insert_one(user_data)

    @staticmethod
    async def get_user_by_id(user_id):
        return await db.users.find_one({'_id': user_id})

    @staticmethod
    async def update_user(user_id, update_data):
        return await db.users.update_one({'_id': user_id}, {'$set': update_data})

    @staticmethod
    async def delete_user(user_id):
        return await db.users.delete_one({'_id': user_id})
